package impleDao;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import modelo.Cliente;
import dao.ClienteDAO;

public class ClienteImple extends HibernateDaoSupport implements ClienteDAO
{
	private static Session session;
	private static Transaction tx;
	
	private void iniciaOperacion() throws HibernateException {
	 	session = getSession();
	 	tx = session.beginTransaction();
	 }

	 private void manejaExcepcion(HibernateException he) throws HibernateException {
		 tx.rollback();
		 throw new HibernateException("ERROR en la capa de acceso a datos", he);
	 }

	@Override
	public Cliente find(int idCli)
	{
		// TODO Auto-generated method stub
		Cliente cliente=null;
		try{
			iniciaOperacion();
			cliente=(Cliente)session.get(Cliente.class,idCli);
		}finally{
			session.close();
		}
		return cliente;
	}

}
